package com.soft.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.soft.entity.User;
import com.soft.service.UserService;
import java.util.List;

@RequestMapping("/user")
@RestController
public class UserController {
    
    @Autowired
    private UserService userService;
    
    @RequestMapping("/queryAllUser")
    public List<User> queryAll() {
        return userService.queryAll();
    }
    @RequestMapping("/queryByName")
    public List<User>queryByName(String name){
    	return userService.queryByName(name);
    }
    @RequestMapping("/insertOne")
    public String insertOne(String name, String email) {
        int num = userService.insertOne(name, email);
        if(num == 1) {
            return name + " 加入成功";
        } else {
            return name + " 加入失败";
        }
    }
    
    @RequestMapping("/deleteById") 
    public String deleteById(int id) {
        int num = userService.deleteById(id);
        if(num == 1) {
            return "删除成功";
        } else {
            return "删除失败";
        }
    }
}